<?php
//学习资讯
class studyAction extends Action{
	function index(){
		
		pubAction::get_slist();
		$this->display('default@study');
	}
	
	function lists(){
		$surl = addslashes($_GET['surl']);
		
		//分类信息
		$user = D('study_sort');
		$lab = $user->where('surl="'.$surl.'"')->find();
		$this->assign('lab',$lab);
		
		/* 列表信息 */
		$study = D('study');

		//分页
		$where = 'sid='.$lab['sid'];
		$size=8;
		$p = intval($_GET['p']);
		$p = $p==0 ? 1 : $p;
		$start = ($p-1)*$size;
		$count = $study->where($where)->count();
		
		import('ORG.Util.Page');
		$page = new Page($count,$size);
		$str = $page->myshow('/study-'.$lab['surl'].'/');
		$this->assign('str',$str);
		
		$list = $study->where($where)->limit("$start,$size")->findAll();
		//echo $study->getlastsql();
		$this->assign('list',$list);
		
		pubAction::get_slist();
		$this->display('default@study_lists');
	}
	
	function show(){
		$id = intval($_GET['id']);
		$user = D('study');
		$lab = $user->where('id='.$id)->find();
		
		$study_sort = D('study_sort');
		$slab = $study_sort->where('sid="'.$lab['sid'].'"')->find();
		
		$this->assign('lab',$lab);
		$this->assign('slab',$slab);
		
		pubAction::get_slist();
		$this->display('default@study_show');
	}
}
?>